<?php

function get_header()
{
	global $data;
	$CI = &get_instance();
	$CI->load->view("header", $data);
}

function get_sidebar()
{
	global $data;
	$CI = &get_instance();
	$CI->load->view("sidebar", $data);
}

function get_footer()
{
	global $data;
	$CI = &get_instance();
	$CI->load->view("footer", $data);
}

function uye_girdi()
{
	global $data;
	$CI = &get_instance();
	return $CI->uyeler->girdi();
}

function kullanici_adi()
{
	global $data;
	$CI = &get_instance();
	return $CI->uyeler->al("kullanici_adi");
}

function iddenKadi($id)
{
	global $data;
	$CI = &get_instance();
	return $CI->uyeler->iddenKadi($id);	
}

function uye_bilgi($anahtar,$id = "")
{
	global $data;
	$CI = &get_instance();
	return $CI->uyeler->al($anahtar, $id);
}

function make_time($tarih)
{
	$tarih = explode(" ", $tarih);
	
	$gun = $tarih[0];
	$saat = $tarih[1];
	
	$gun = explode(".", $gun);
	$saat = explode(":", $saat);
	
	return mktime($saat[0],$saat[1],0,$gun[1],$gun[0],$gun[2]);
}

function time_since($original) {
    // array of time period chunks
    $chunks = array(
        array(60 * 60 * 24 * 365 , 'yıl'),
        array(60 * 60 * 24 * 30 , 'ay'),
        array(60 * 60 * 24 * 7, 'hafta'),
        array(60 * 60 * 24 , 'gün'),
        array(60 * 60 , 'saat'),
        array(60 , 'dakika')
    );
    
    $today = time(); /* Current unix time  */
    $since = $today - $original;
    
    // $j saves performing the count function each time around the loop
    for ($i = 0, $j = count($chunks); $i < $j; $i++) {
        
        $seconds = $chunks[$i][0];
        $name = $chunks[$i][1];
        
        // finding the biggest chunk (if the chunk fits, break)
        if (($count = floor($since / $seconds)) != 0) {
            // DEBUG print "<!-- It's $name -->\n";
            break;
        }
    }
    
	
	if ($count == 0)
		$count = 1;
		
    $print = ($count == 1) ? 'birkaç saniye' : "$count {$name}";
    
    if ($i + 1 < $j) {
        // now getting the second item
        $seconds2 = $chunks[$i + 1][0];
        $name2 = $chunks[$i + 1][1];
        
        // add second item if it's greater than 0
        if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
            $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}";
        }
    }
    return $print;
}


	
?>